<?php
/**
 * Created by PhpStorm.
 * User: 秋刀鱼
 * Date: 2018/8/7
 * Time: 10:27
 */

namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use yii\db\query;
use yii\filters\Cors;
use yii\helpers\ArrayHelper;
use yii\web\models;
use \common\helps\tools;//使用工具类
use yii\db\ActiveRecord;
use yii\db\Connection;

/**
 * Research controller
 */
class SpecialistController extends Controller
{
    public function init()
    {
        $this->enableCsrfValidation = false;
    }


    /**
     * view
     * title 添加待验收
     * @return string
     */
    public function actionAddcheck()
    {
        return $this->render('addCheck');
    }

    /**
     * view
     * title 待验收列表
     * @return string
     */
    public function actionPreparecheck()
    {
        return $this->render('prepareCheck');
    }

    /**
     * view
     * title 已验收列表
     * @return string
     */
    public function actionChecked()
    {
        return $this->render('checked');
    }


    /**
     * 接口
     * title 专家验收
     * @return string
     */
    public function actionCheckPortSpecial(){
        header('Access-Control-Allow-Origin:*');
        $post = Yii::$app->request->post();
        $uid = $post['uid'];
        $token = $post['token'];
        //token验证
        $checkToken = tools::checkToken('admin_'.$uid,$token);
        if($checkToken != 4){
            return tools::ajax_return('9','token过期,请重新登录',[$checkToken]);
        }

        $special = new \app\models\Special;
        $add = $special->checkSpecial($uid);

        if($add == 2){
            return tools::ajax_return_error('1','验收失败',[]);
        }

        return tools::ajax_return('0','验收成功',$add);

    }



}